<?php

namespace app\admin\controller;

use app\common\controller\Backend;

/**
 * 地区管理
 *
 * @icon fa fa-circle-o
 */
class Area extends Backend
{

    /**
     * Area模型对象
     * @var \app\admin\model\Area
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\Area;
        $this->view->assign("levelList", $this->model->getLevelList());
    }



    /**
     * 查看省份
     */
    public function province()
    {
        $provinceList = $this->model->where('level', 1)->order('id ASC')->select();
        return json([
            "list" => $provinceList,
            "total" => count($provinceList)
        ]);
    }
    /**
     * 查看省份
     */
    public function city($province_id)
    {
        $provinceList = $this->model->where('pid', $province_id)->order('id ASC')->select();
        return json([
            "list" => $provinceList,
            "total" => count($provinceList)
        ]);
    }
}
